<?php

/**
 * This is the model class for table "{{mobile_phone}}".
 *
 * The followings are the available columns in table '{{mobile_phone}}':
 * @property integer $moep_id
 * @property integer $moep_type
 * @property double $moep_price
 * @property integer $moep_vote_num
 * @property integer $moep_vote_score
 * @property string $moep_log
 * @property string $moep_name
 * @property string $moep_os
 * @property double $moep_screen_size
 * @property integer $moep_pix_x
 * @property integer $moep_pix_y
 */
class MobilePhone extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return MobilePhone the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{mobile_phone}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('moep_type, moep_price, moep_vote_num, moep_vote_score, moep_name, moep_os, moep_pix_y', 'required'),
			array('moep_type, moep_vote_num, moep_vote_score, moep_pix_x, moep_pix_y', 'numerical', 'integerOnly'=>true),
			array('moep_price, moep_screen_size, moeb_id, moep_hot_sale', 'numerical'),
			array('moep_log', 'length', 'max'=>100),
			array('moep_name', 'length', 'max'=>50),
			array('moep_os', 'length', 'max'=>32),
			array('moep_desc', 'length', 'max'=>250),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array(' moep_type, moep_price,    moep_name, moep_os,   ', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'moep_id' => '手机编号',
			'moep_type' => '手机类型',
			'moep_price' => '手机价格',
			'moep_market_price' => '市场价格',
			'moep_vote_num' => '投票人数',
			'moep_vote_score' => '总投票数',
			'moep_log' => '手机log',
			'moep_name' => '手机名称',
			'moep_os' => '操作系统',
			'moep_screen_size' => '屏幕尺寸',
			'moep_pix_x' => 'X像素',
			'moep_pix_y' => 'Y像素',
			'moeb_id'	 => '手机品牌',
			'moep_desc'  => '手机简单描述',
			'moep_hot_sale' => '是否热销产品',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('moep_type',$this->moep_type);

		$criteria->compare('moep_price',$this->moep_price);


		$criteria->compare('moep_name',$this->moep_name,true);

		$criteria->compare('moep_os',$this->moep_os,true);


		return new CActiveDataProvider('MobilePhone', array(
			'criteria'=>$criteria,
		));
	}
}